from typing import List, Optional
from pydantic import BaseModel, Field
from .base import BaseSchema
from .permission import PermissionSchema

class MenuBase(BaseSchema):
    """菜单基础模型"""
    name: str = Field(..., max_length=100, description="菜单名称")
    path: Optional[str] = Field(None, max_length=255, description="菜单路径")
    component: Optional[str] = Field(None, max_length=255, description="组件路径")
    icon: Optional[str] = Field(None, max_length=100, description="菜单图标")
    parent_id: Optional[int] = Field(None, description="父菜单ID")
    sort_order: Optional[int] = Field(0, description="排序号")
    is_visible: Optional[bool] = Field(True, description="是否可见")

class MenuCreate(MenuBase):
    """创建菜单模型"""
    permission_ids: Optional[List[int]] = Field(None, description="权限ID列表")

class MenuUpdate(MenuBase):
    """更新菜单模型"""
    permission_ids: Optional[List[int]] = Field(None, description="权限ID列表")

class MenuSchema(MenuBase):
    """菜单响应模型"""
    children: List["MenuSchema"] = Field([], description="子菜单列表")
    permissions: List[PermissionSchema] = Field([], description="权限列表")